package change

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/openmerch/change"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// ChangeService 开放商户变更服务
type ChangeService struct {
	*services.BaseService
}

// NewChangeService 创建变更服务实例
func NewChangeService(config *core.Config) *ChangeService {
	return &ChangeService{
		BaseService: services.NewBaseService(config),
	}
}

// ChangeRateInfo 变更费率信息
func (s *ChangeService) ChangeRateInfo(request *change.RateInfoChangeRequest) (*change.RateInfoChangeResponse, error) {
	response := change.NewRateInfoChangeResponse()
	err := s.Post(request, response, "/open/merch/access/rate-info/modify")
	return response, err
}

// ChangeSettleAccount 变更结算账户
func (s *ChangeService) ChangeSettleAccount(request *change.SettleAccountChangeRequest) (*change.SettleAccountChangeResponse, error) {
	response := change.NewSettleAccountChangeResponse()
	err := s.Post(request, response, "/open/merch/access/settle-info/modify")
	return response, err
}

// ChangeMerchInfo 变更商户信息
func (s *ChangeService) ChangeMerchInfo(request *change.MerchInfoChangeRequest) (*change.MerchInfoChangeResponse, error) {
	response := change.NewMerchInfoChangeResponse()
	err := s.Post(request, response, "/open/merch/access/merch-info/modify")
	return response, err
}

// ModifyFixedWithdraw 修改商户定点清算
func (s *ChangeService) ModifyFixedWithdraw(request *change.FixedWithdrawModifyRequest) (*change.FixedWithdrawModifyResponse, error) {
	response := change.NewFixedWithdrawModifyResponse()
	err := s.Post(request, response, "/open/merch/access/fixed-withdraw/modify")
	return response, err
}

// ModifySettleRule 修改商户结算规则
func (s *ChangeService) ModifySettleRule(request *change.SettleRuleModifyRequest) (*change.SettleRuleModifyResponse, error) {
	response := change.NewSettleRuleModifyResponse()
	err := s.Post(request, response, "/open/merch/access/settle-rule/modify")
	return response, err
}

// ModifySignInfo 修改商户签约信息
func (s *ChangeService) ModifySignInfo(request *change.SignInfoModifyRequest) (*change.SignInfoModifyResponse, error) {
	response := change.NewSignInfoModifyResponse()
	err := s.Post(request, response, "/open/merch/access/sign-info/modify")
	return response, err
}
